package com.fan.websocket;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;
import java.net.URISyntaxException;

/**
 * @Description:
 * @Author: Fan
 * @Date: 2021/10/12 21:45
 * @Version 1.0
 **/
public class CustomerWebSocketClient extends WebSocketClient {

    public CustomerWebSocketClient(URI serverUri) {
        super(serverUri);
    }

    @Override
    public void onOpen(ServerHandshake handshakedata) {

    }

    @Override
    public void onMessage(String message) {
        System.out.println("received:" + message);
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {

    }

    @Override
    public void onError(Exception ex) {

    }

    public static void main(String[] args) throws URISyntaxException {
        CustomerWebSocketClient client = new CustomerWebSocketClient(new URI("ws://localhost:8887"));
        client.connect();
    }
}
